package test01;

import test01.AnthropicClient;
import test01.GeminiClient;
import test01.OpenAIClient;
import test01.AnthropicAdapter;
import test01.GoogleAdapter;
import test01.OpenAIAdapter;

public class AIServicePlatform {
    public static void main(String[] args) {
        // 创建不同厂商的适配器
        UnifiedAIService openAIService = new OpenAIAdapter(new OpenAIClient());
        UnifiedAIService googleService = new GoogleAdapter(new GeminiClient());
        UnifiedAIService anthropicService = new AnthropicAdapter(new AnthropicClient());

        String prompt = "请解释适配器模式";

        // 使用统一接口调用不同AI服务 - 客户端代码无需关心底层实现差异
        System.out.println("=== OpenAI ===");
        String openAIResult = openAIService.generateText(prompt);
        System.out.println("结果: " + openAIResult);

        System.out.println("\n=== Google Gemini ===");
        String googleResult = googleService.generateText(prompt);
        System.out.println("结果: " + googleResult);

        System.out.println("\n=== Anthropic Claude ===");
        String anthropicResult = anthropicService.generateText(prompt);
        System.out.println("结果: " + anthropicResult);

        // 动态切换AI服务
        System.out.println("\n=== 动态切换示例 ===");
        UnifiedAIService currentService = openAIService; // 初始使用OpenAI

        // 根据条件动态切换服务
        boolean useGoogle = true;
        if (useGoogle) {
            currentService = googleService;
        }

        String dynamicResult = currentService.generateText("动态切换测试");
        System.out.println("动态结果: " + dynamicResult);
    }
}